import pymysql

con = pymysql.connect(
    host='localhost',
    user='root',
    password='123456',
    charset='utf8')

cur = con.cursor()

cur.execute("use GameUser;")

sql_insert = """insert into users(user_id,passwd,score) values ("202176564",210010,0)"""

try:
    cur.execute(sql_insert)
    # 提交
    con.commit()
    print("开始数据库插入操作")
except Exception as e:
    con.rollback()
    print("数据插入失败，回滚")
finally:
    con.close()
